package com.lihaozhe.orderservice.client;

import com.lihaozhe.orderservice.feign.PaymentServiceFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.Map;

/**
 * 支付服务Feign客户端接口
 * <p>
 * 演示更复杂的Feign使用场景：
 * - 请求体参数
 * - 响应处理
 * - 错误处理
 * </p>
 *
 * @author 李昊哲
 * @version 1.0.0
 */
@FeignClient(
    name = "payment-service",
    path = "/api/payments",
    fallback = PaymentServiceFallback.class  // 降级处理类
)
public interface PaymentServiceClient {

  /**
   * 创建支付
   * 对应 payment-service 的 POST /api/payments
   *
   * @param paymentRequest 支付请求
   * @return 支付结果
   */
  @PostMapping
  Map<String, Object> createPayment(@RequestBody Map<String, Object> paymentRequest);

  /**
   * 查询支付状态
   * 对应 payment-service 的 GET /api/payments/{paymentId}/status
   *
   * @return 支付状态
   */
  @PostMapping("/{paymentId}/status")
  Map<String, Object> getPaymentStatus( @RequestBody Map<String, Object> request);

  /**
   * 退款
   * 对应 payment-service 的 POST /api/payments/refund
   *
   * @param refundRequest 退款请求
   * @return 退款结果
   */
  @PostMapping("/refund")
  Map<String, Object> refund(@RequestBody Map<String, Object> refundRequest);
}
